package com.bolt.admin.module.sys.entity;

import com.bolt.support.spring.jpa.entity.BaseTreeAuditingEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;


/**
 * Auto Generate Javadoc
 *
 * @author　米超 日期:2018-02-27 14:20:36
 * 机构信息
 **/

@Accessors(chain = true)
@Access(AccessType.FIELD)
@Entity
@Table(name = "sys_org")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@Data
public class OrgEntity extends BaseTreeAuditingEntity <String, OrgEntity> {

    public OrgEntity(String id) {
        this.id = id;
    }

    @Id
    @Column(length = 40)
    @GeneratedValue(generator = "hibernate-uuid")
    @GenericGenerator(name = "hibernate-uuid", strategy = "org.hibernate.id.UUIDGenerator")
    private String id;

    @Column(name = "name", length = 128)
    private String name;

    @Column(name = "code", length = 60)
    private String code;

    @Column(name = "area_code", length = 20, insertable = false, updatable = false)
    private String areaCode;

    /**
     * * 邮箱
     **/
    @Column(name = "email", length = 255)
    private String email;

    /**
     * * 备注信息
     **/
    @Column(name = "remarks", length = 255)
    private String remarks;


    @Column(name = "address", length = 255)
    private String address;

    @Column(name = "zip_code", length = 12)
    private String zipCode;

    @Column(name = "master", length = 100)
    private String master;

    @Column(name = "tel", length = 19)
    private String tel;

    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "area_code", referencedColumnName = "area_code")
    private AreaEntity areaInfo;


}